package com.lsl.observer_pattern.example2.generic;

import com.lsl.abstract_factory.example2.App;
import com.lsl.observer_pattern.example2.WeatherType;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * description:
 *
 * @author: liushengli
 * data: 2023/1/13
 */
@Slf4j
public class GWeather extends Observable<GWeather, Race, WeatherType> {
    private static final Logger logger = LoggerFactory.getLogger(GWeather.class);



    private WeatherType currentWeather;

    public GWeather() {
        currentWeather = WeatherType.SUNNY;
    }

    /**
     * Makes time pass for weather.
     */
    public void timePasses() {
        var enumValues = WeatherType.values();
        currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length];
        logger.info("The weather changed to {}.", currentWeather);
        notifyObservers(currentWeather);
    }
}